{extend name="base" /} {block name="seo"}
<title>用户中心 - {$site.name}</title>
<meta name="keywords" content="{$site.keywords}">
<meta name="description" content="{$site.description}">
{/block}
{block name="css"}
<link href="__HOME__/css/user.css" rel="stylesheet" type="text/css">
{/block}
{block name="body"}
<div class="container">
    <div class="user">
        {include file="index/menu"}
        <div class="user-info user-box fl">
            <div class="title">
                个人资料
                <span><script>
           var now = (new Date()).getHours();
           if (now > 0 && now <= 6) {
               document.write("午夜好，")
           } else if (now > 6 && now <= 11) {
               document.write("早上好，")
           } else if (now > 11 && now <= 14) {
               document.write("中午好，")
           } else if (now > 14 && now <= 18) {
               document.write("下午好，")
           } else {
               document.write("晚上好，")
           }
                </script>{$user.nickname}</span> <span style="line-height:30px;float: right"><a
                    href="{:url('user/index/edit')}"><i class="layui-icon layui-icon-set"></i></a></span>
            </div>

            <div class="i-info layui-row">
                <div class="layui-col-md8 layui-clear" style="padding-bottom: 10px">

                    <a class="info-img">
                        <img src="{$user.avatar}" onerror="this.src='/static/common/images/a3o.png'">
                    </a><input class="layui-upload-file" type="file" accept="undefined" name="file">

                    <div class="info-info">
                        <h3 class="nick"><i class="iconfont icon-nan"></i>{$user.nickname}<font>{$user.uuid}</font>
                            <!--                        <b class="jp">投稿作者</b>-->
                        </h3>
                        <p class="intr">{$user.description}</p>
                    </div>

                </div>
                <div class="layui-col-md4">
                    {:hooks('sign.sign_btn')}
                </div>
            </div>


            <div class="data ">
                <ul>
                    <li>
                        <h3>账户余额</h3>
                        <p>{$user.score} 个{:sysconfig('score.score_name')}</p>
                        <span><i class="fa fa-cloud-download fa-fw"></i></span>
                    </li>
                    <!--                    <li>-->
                    <!--                        <h3>会员级别</h3>-->
                    <!--                        <p>白嫖会员 <font color="red">会员到期</font> </p>-->
                    <!--                        <span><i class="fa fa-paper-plane fa-fw"></i></span>-->
                    <!--                    </li>-->
                    <li>
                        <h3>我的评论</h3>
                        <p>{$user.comment_num}条</p>
                        <span><i class="fa fa-comments fa-fw"></i></span>
                    </li>
                    <li>
                        <h3>我的收藏</h3>
                        <p>{$user.favorite_num}篇</p>
                        <span><i class="fa fa-cloud-download fa-fw"></i></span>
                    </li>
                    <!--                    <li>-->
                    <!--                        <h3>我的收藏</h3>-->
                    <!--                        <p>{$user.favorite_num}</p>-->
                    <!--                        <span><i class="fa fa-cloud-download fa-fw"></i></span>-->
                    <!--                    </li>-->
                </ul>
            </div>

            <div class="list">


                <ul class="my-info">
                    <li>
                        <h3>用户名</h3>
                        <span>{$user.username}</span>
                    </li>
                    <li>
                        <h3>我的昵称</h3>
                        <span>{$user.nickname}</span>
                    </li>
                    <li>
                        <h3>性别</h3>
                        <span>{if $user.sex eq 1}男{elseif $user.sex eq 2}女{else /}未知{/if}</span>
                    </li>


                    <li>
                        <h3>我的QQ</h3>
                        <span><?php echo $user['qq']?substr_replace($user['qq'], '*****', -2, 3):'---'; ?></span>
                    </li>
                    <li>
                        <h3>邮箱号码</h3>
                        <span><?php echo $user['email']?substr_replace($user['email'], '********', -7, 4):'暂未绑定'; ?></span>
                    </li>
                    <li>
                        <h3>手机号码</h3>
                        <span><?php echo $user['mobile']?substr_replace($user['mobile'], '********', -2, 4):'暂未绑定'; ?></span>
                    </li>
                    <li>
                        <h3>介绍</h3>
                        <span>{$user.description}</span>
                    </li>
                    <li>
                        <h3>专属头衔</h3>
                        <span>{$user.rank}</span>
                    </li>

                    <li>
                        <h3>注册时间</h3>
                        <span>{$user.create_time}</span>
                    </li>

                    <li style="width: 100%;">
                        <h3>邀请注册链接 </h3>
                        <span>{:domain_url('/user/login/register')}?uid={$user.id}</span>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    var layer;
    layui.use(['layer', 'upload'], function () {
        layer = layui.layer;
        var upload = layui.upload;

        /* 级别的解释 */
        $(".jp").hover(function (e) {
            layer.tips('普通会员：指正常用户<br/>投稿作者：分享投稿过的<br/>金牌作者：长期投稿 并享有极高通过率的作者，此类作者可享受本站优先通过和自动审核通过的特权', $(this), {
                tips: [1, '#2c2c2c'],
                area: ['310px'],
                time: 0
            });
        }, function (e) {
            layer.closeAll();
        });

        /*更换头像*/
        var uploadInst = upload.render({
            elem: '.info-img',
            auto: false,
            choose: function (obj) {
                var files = obj.pushFile();
                obj.preview(function (index, file, result) {
                    files = result;
                });
                layer.open({
                    type: 2,
                    shadeClose: true,
                    acceptMime: 'image/*',
                    title: "头像裁剪",
                    area: ['400px', '397px'],
                    skin: 'atuikeLayerSkin1 trim',
                    content: [config.api.trim, 'no'],
                    btn: 0,
                    success: function (layero, index) {
                        document.getElementById("layui-layer-iframe" + index).contentWindow.selectImg(files);
                    },
                    //end:location.reload
                });
            }
        });
    });

    function setImgData(base64) {
        request({
            url: config.api.user_changeinfo,
            data: {avatar_base64: encodeURIComponent(base64)},
            success: function (result) {
                if (result.code) {
                    layer.closeAll();
                    $('.info-img').find("img")[0].src = result.data.src + "?_=" + new Date().getTime();
                } else {
                    layer.msg(result.msg)
                }
            }
        });
    }
</script>
{/block}